'''
    调用Base页
'''
import time

from month.Base.Base import Base
from selenium.webdriver.common.by import By
class Page2(Base):
    # 定位输入框
    search_bd_loc = (By.ID,'chat-textarea')
    def search_bd(self):
        self.send_keys(self.search_bd_loc,'时间')
    # 定位搜索按钮
    but_submit_loc = (By.ID,'chat-submit-button')
    def but_submit(self):
        self.click(self.but_submit_loc)
    # 断言2
    dy2_loc = (By.XPATH,'//*[@id="2"]/div/h3/a/div/div/p/span/span')
    def dy2(self):
        return self.text(self.dy2_loc)
    # 点击
    click_sj_loc = (By.XPATH, '//*[@id="2"]/div/h3/a/div/div/p/span/span')
    def click_sj(self):
        self.click(self.click_sj_loc)
        self.window()
    dy3_loc =(By.XPATH,'//*[@id="root"]/div/div[1]/div[5]/div[1]/div/dl[2]/dt/a')
    def dy3(self):
        return self.text(self.dy3_loc)

    def search_baidu_002(self):
        self.open_url('https://www.baidu.com/')
        self.search_bd()
        self.but_submit()
        print(self.dy2())
        try:
            assert '时间(哲学定义) - 百度百科' == self.dy2()
        except Exception as e:
            print(e)
        self.click_sj()
        print(self.dy3())
        try:
            assert '秒懂百科' == self.dy3()
        except Exception as e:
            print(e)